package com.tr.rentcar.controller.houtai.admin;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tr.rentcar.model.dao.AdminroleDao;
@WebServlet("/adminroletianjia")
public class AdminroletianjiaControllor extends HttpServlet {
	AdminroleDao AdminroleDao=new AdminroleDao();
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		try {
		String pid=req.getParameter("pid");
		Integer Pid=Integer.parseInt(pid);
		if(Pid==1){
		String arname=req.getParameter("arname");
		AdminroleDao.save(arname);
		}
		if(Pid==2){
			String arname=req.getParameter("arname");
			String id=req.getParameter("arid");
			System.out.println(id);
			 Integer arid =Integer.parseInt(id);
			AdminroleDao.update(arname,arid );
		}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		resp.sendRedirect(req.getContextPath()+"/houtaiadminrole");
	}
}
